-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
docs(types) mention computed object key syntax and correct existing case #3323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Preview is ready Built with commit ff14ccf https://deploy-preview-3323--webpackjsorg-netlify.netlify.com |
I would argue that using a TypeScript-like syntax instead of making up our own is a better solution. First, both JS veterans and newbies alike benefit from it: to the former the syntax might already be well known and intuitive, while for the latter it allows them to get familiar with a syntax they are likely to encounter later on as they learn the language. Second, TypeScript has already solved the problem of ambiguous types and difficulties in expressing them. Due to the projects nature it had to come up with ways of denoting the types. Next, I want to look at the current methods of denoting the types to determine problems with them. In arrays, the usage of a comma to denote different possible types is confusing, as commas are already used to separate values in an array. In objects the lack of a separator between the property name and value can also be confusing. Most developers are already used to the concept of the two being separated by Additionally the usage of Lastly, while using spaces to separate possible types seems like a good idea, it falls apart as soon as we are inside of an array or an object. I'm not exactly opposed to the idea of separating the top level types with spaces, as it can help differentiate between them (even if the difference between the white background and the |
Just remembered that you mentioned that having different value types in a single array is not something that has happened, but it's not unheard of. ESLint, for example, uses I also forgot to address default values, but that's because the way they're currently handled seems sane. I don't see a reason to change that. |
@opl- Yes, I have the same concerns when we decide to do this. Perfect solution would be use the same types notations as webpack source code (if available). |
Thanks for reviews guys, looks like we can up an issue to discuss typescript usage and potential impact |
@opl- @montogeek one of you guys want to take the lead on it? |
<>
syntax for computed object props to the writers guideReference of current usage: https://webpack.js.org/configuration/entry-context/#entry